import Vue from 'vue'
Date.prototype.format = function(dirtyFormatStr, dirtyOptions = { locale: require('date-fns/locale/zh_cn') }) {
  return require('date-fns/format')(this, dirtyFormatStr, dirtyOptions)
}

/*
 * xxx | dateFormat('YYYY/MM/DD')
 */
Vue.filter('dateFormat', (val, format = 'YYYY-MM-DD HH:mm:ss') => {
  val *= '1'.padEnd((13 - val.toString().length) + 1, 0)

  return require('date-fns/parse')(val).format(format)
})
